import "reflect-metadata";
// 其实可一个iController传递路径前缀，可以为空也可以空串，也可以字符串，还可以是对象
interface ControllerOptions {
  prefix: string;
}
export function Controller(): ClassDecorator;
export function Controller(prefix: string): ClassDecorator;
export function Controller(options: ControllerOptions): ClassDecorator;
export function Controller(
  prefixOrOptions?: string | ControllerOptions
): ClassDecorator {
  let options: ControllerOptions = { prefix: "" };
  if (typeof prefixOrOptions === "string") {
    options.prefix = prefixOrOptions;
  } else if (typeof prefixOrOptions === "object") {
    options = prefixOrOptions;
  }
  // 这里是类装饰器，装饰的控制器这个类
  return (target: Function) => {
    Reflect.defineMetadata("prefix", options.prefix || "", target);
  };
}
